#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    string reverseStr(string s, int k) {
        for(int i = 0; i < s.size(); i += (2 * k)){
            if(i + k < s.size()){
                reverse(s.begin() + i, s.begin() + i + k);
                continue;
            }
            else reverse(s.begin() + i, s.begin() + s.size());
        }
        return s;
    }
};

int main()
{
    string s = "abcdefg";
    int k = 2;
    cout << Solution().reverseStr(s, k) << endl;
    return 0;
}